<template>
	<view>
		<view>
			<!-- <image class="top" :src="imgurl+'popup.png'" @tap="Show"></image> -->
		</view>
		<view class="main">
			<view class="main-top flex">
				<image :src="imgurl+'user.png'"></image>
				<input @input="getPhone" placeholder="请输入用户名/手机号" placeholder-class="plceholdercss" />
			</view>
			<view class="main-center flex">
				<image :src="imgurl+'pass.png'"></image>
				<input @input="getPass" type="password" placeholder="请输入密码" placeholder-class="plceholdercss" />
			</view>
			<view class="main-bottom flex">
				<text class="findpass" @tap="findPass">找回密码</text>
				<text class="zhuce" @tap="Register">立即注册</text>
			</view>
		</view>
		<view class="denglu" @tap="Login">立即登录</view>

		<!-- #ifdef  MP-WEIXIN -->
		<view class="footer flex">
			<view class="footer-item row" @tap="chatLogin">
				<image :src="imgurl+'weichat.png'"></image>
				<text>微信登录</text>
			</view>
			<view class="footer-item row" @tap="noteLogin">
				<image :src="imgurl+'messages.png'"></image>
				<text>短信登录</text>
			</view>
		</view>
		<!-- #endif -->
		<!-- #ifdef  H5 -->
		<view class="footer">
			<view class="footer-item row">
				<image :src="imgurl+'QQ.png'"></image>
				<text>QQ登录</text>
			</view>
			<view class="footer-item row">
				<image :src="imgurl+'weichat.png'"></image>
				<text>微信登录</text>
			</view>
			<view class="footer-item row">
				<image :src="imgurl+'messages.png'"></image>
				<text>短信登录</text>
			</view>
		</view>
		<!-- #endif -->
		<!-- <view class="bottom">登录即代表您同意问吧<text>《用户服务协议》</text>和<text>《隐私条款》</text></view> -->
		<!-- <view class="popup" v-if="show">
			<view class="popup-main">
				<image :src="imgurl+'cuo.png'" @tap="Hide"></image>
				<view class="main-item" @tap="skipIndex">首页</view>
				<view class="main-item">问卷调查介绍</view>
				<view class="main-item other">问卷模板</view>
				<view class="popup-footer flex">
					<view class="dl">登录</view>
					<view class="zc">注册</view>
				</view>
			</view>
		</view> -->
	</view>
</template>

<script>
	import api from "@/common/api.js";
	import {
		baseURL
	} from "@/common/http.js";
	import app from "../../App.vue"
	export default {

		data() {
			return {
				imgurl: "",
				username: "",
				show: false,
				pass: ''
			};
		},
		methods: {
			getPhone(e) {
				this.username = e.detail.value
			},
			getPass(e) {
				this.pass = e.detail.value
			},
			Login() {
				if (this.pass != '' && this.username != '') {
					let data = {
						api: 'nameden',
						password: this.pass,
						name: this.username
					}
					api.look(data).then(res => {
						if (res && res.code === 200) {
							uni.setStorageSync('message', res.date)
							uni.reLaunch({
								url: '../index/index'
							})
						} else {
							uni.showToast({
								title: '请输入正确的用户名/手机号和密码',
								duration: 1500,
								icon: 'none'
							})
						}
					}).catch(err => {
						console.log(err)
					})
				} else {
					if (this.username == '') {
						uni.showToast({
							icon: 'none',
							title: '请输入用户名',
							duration: 1500
						})
					} else if (this.pass == '') {
						uni.showToast({
							title: '请输入密码',
							duration: 1500,
							icon: 'none'
						})
					}
				}
			},
			Show() {
				this.show = true
			},
			Hide() {
				this.show = false
			},
			//点击找回密码
			findPass() {
				uni.navigateTo({
					url: "../password/findPassOne/findPassOne"
				})
			},
			//点击注册
			Register() {
				uni.navigateTo({
					url: "../register/registerOne/registerOne"
				})
			},
			//微信登录
			chatLogin() {
				uni.getStorage({
					key: 'message',
					success: () => {
						let data = {
							id: uni.getStorageSync('message')[0].id,
							fen: 'login',
							api: 'wenfenzen'
						}
						api.look(data).then(res => {
							console.log(res)
						}).catch(err => {
							console.log(err)
						})
						uni.navigateTo({
							url: '../index/index'
						})
					},
					fail: () => {
						uni.navigateTo({
							url: "../chatLogin/chatLogin"
						})
					}
				})
			},
			noteLogin() {
				uni.navigateTo({
					url: "../noteLogin/noteLogin?login=" + true
				})
			}
		},
		onShareAppMessage(options) {
			let shareObj = {
				success: (res) => {
					if (res.errMsg == 'shareAppMessage:ok') {
						uni.showToast({
							title: '分享成功',
							icon: 'success',
							duration: 1500
						})
					}
				},
				fail: () => {
					if (res.errMsg == 'shareAppMessage:fail cancel') {
						uni.showToast({
							title: '取消分享',
							icon: 'none',
							duration: 2000
						})
					} else if (res.errMsg == 'shareAppMessage:fail') {
						// 转发失败，其中 detail message 为详细失败信息
					}
				},
				complete: () => {
					// 转发结束之后的回调（转发成不成功都会执行）
				}
			}
		},
		onLoad() {
			this.imgurl = app.globalData.imgurl
		}
	}
</script>

<style lang="scss">
	.top {
		width: 90rpx;
		height: 90rpx;
		position: fixed;
		top: 40rpx;
		right: 50rpx;
	}

	.main {
		margin-top: 250rpx;
	}

	.main-top,
	.main-center {
		margin: 0 auto;
		width: 650rpx;
		height: 100rpx;
		border-bottom: 1rpx solid #999999
	}

	.main-top image,
	.main-center image {
		width: 48rpx;
		height: 48rpx;
	}

	.main-bottom {
		justify-content: space-between;
		margin: 0 auto;
		width: 650rpx;
		height: 100rpx;

		.findpass {
			width: 130rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
		}

		.zhuce {
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #209FFC;
			border-bottom: 1rpx solid #209FFC;
		}
	}

	.denglu {
		width: 650rpx;
		height: 100rpx;
		margin: 0 auto;
		margin-top: 50rpx;
		background: #209FFC;
		border-radius: 50rpx;
		font-size: 40rpx;
		line-height: 100rpx;
		text-align: center;
		font-weight: 500;
		color: #fff;
	}

	.footer {
		width: 650rpx;
		margin: 0 auto;
		justify-content: center;
		margin-top: 60rpx;

		.footer-item {
			width: 200rpx;
			align-items: center;

			image {
				width: 90rpx;
				height: 90rpx;
			}

			text {
				color: #333;
				font-size: 24rpx;
				font-weight: 500;
			}
		}

	}

	.bottom {
		width: 650rpx;
		position: fixed;
		left: 50rpx;
		bottom: 20rpx;
		text-align: center;
		font-size: 18rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #666;

		text {
			color: #209FFC
		}
	}

	.popup {
		position: fixed;
		top: 0;
		right: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.7);
		z-index: 1000;

		.popup-main {
			position: absolute;
			right: 0;
			top: 0;
			width: 40%;
			height: 100%;
			background: #fff;

			image {
				width: 30rpx;
				height: 30rpx;
				margin: 20rpx 0 0 30rpx;
			}

			.main-item {
				width: 210rpx;
				height: 100rpx;
				margin: 0 auto;
				line-height: 100rpx;
				border-bottom: 1rpx solid #A4A3A3;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #333;
			}

			.other {
				border-bottom: none;
			}

			.popup-footer {
				position: absolute;
				bottom: 80rpx;
				left: 40rpx;

				.dl {
					width: 100rpx;
					height: 50rpx;
					line-height: 50rpx;
					text-align: center;
					background: #EC6941;
					color: #fff;
					border-radius: 25rpx
				}

				.zc {
					width: 100rpx;
					height: 50rpx;
					line-height: 50rpx;
					text-align: center;
					margin-left: 20rpx;
					color: #EC6941;
					background: #fff;
					border: 1px solid #EC6941;
					border-radius: 25rpx
				}
			}
		}
	}
</style>
